﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;

namespace Host.DataContext
{
    public class QuizDB : DbContext
    {
        public QuizDB()
            : base("QuizDBConnection")
        {
        }

        public DbSet<Highscore> Highscores { get; set; }
        public DbSet<Question> Questions { get; set; }
        public DbSet<Quiz> Quizes { get; set; }

    }

    [Table("Highscore")]
    public class Highscore
    {
        [Key]
        public int ID { get; set; }
        public string Name { get; set; }
        public int Points { get; set; }
        public int QuizID { get; set; }
        [ForeignKey("QuizID")]
        public virtual Quiz Quiz { get; set; }
        

    }

    [Table("Question")]
    public class Question
    {
        [Key]
        public int ID { get; set; }
        public string Text { get; set; }
        public string AnswerA { get; set; }
        public string AnswerB { get; set; }
        public string AnswerC { get; set; }
        public string AnswerD { get; set; }
        public int RightAnswer { get; set; }
        public int Point{ get; set; }
        public int QuizID { get; set; }
        [ForeignKey("QuizID")]
        public virtual Quiz Quiz { get; set; }
    }

    [Table("Quiz")]
    public class Quiz
    {
        [Key]
        public int ID { get; set; }
        public string Name { get; set; }
        public int Difficulty{ get; set; }
        public string Description { get; set; }

        //public virtual IEnumerable<Question> Questions
        //{
        //    get { return Questions.Where(q => q.QuizID == ID); }
        //}
    }
}